package com.example.mine_platform.mapper;

import com.example.mine_platform.pojo.dto.PwdDTO;
import com.example.mine_platform.pojo.entities.User;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface UserMapper extends Mapper<User> {
    @Select("select * from user where phone=#{phone} and deleted=0")
    User getByPhone(String phone);
    @Select("select count(*) from user where phone = #{phone} and deleted=0")
    int existUser(String phone);

    @Select({"<script>",
            "SELECT * FROM user",
            "WHERE deleted=0",
            "<when test='userName!=null'>",
            "AND user_name like concat('%',#{userName},'%')",
            "</when>",
            "</script>"})
    List<User> getUserList(String userName);
    @Update("update user set Password=#{Password} where id=#{userId}")
    void updatePwd(PwdDTO pwdDTO);
    @Select("select count(*) from user where deleted=0")
    int count();
}